<?php
$paging = new paging();
$mod = $_GET['mod'];
$curpg = $_GET['curpg'];
$curpg = (isset($curpg)) ? $curpg : 1;
$gotopage = '?mod=' . $mod . "&act=list";

$where = " where 1 ";
$idcat = 0;
if (isset($_POST['idcat'])) {
    $idcat = $_POST['idcat'];
    if ($idcat != 0)
        $where .= " and idcat = '$idcat'";
}
elseif (isset($_GET['idcat'])) {
    $idcat = $_GET['idcat'];
    if ($idcat != 0)
        $where .= " and idcat = '$idcat'";
}

$db = new MySQL();
$table = "recruitment_item";
$query = "select * from $table $where";
$totalrows = find($query, 'count');

$query = "select * from $table $where order by orderId, id asc limit " . (($curpg - 1) * $perpage) . ", " . $perpage;
$items = find($query);

require_once 'include/js_for_list_with_cat.php';
?>

<div class="page-header">
    <div class="pull-left">Recruitment list</div>
    <div class="pull-right">
        <select class="form-control" name="cbidcat" onchange="submitfrm(this.value);">
            <option value="0">All Category</option>
            <?php echo listNewsCat_Item($idcat, 0, 0, 1, 0, 'recruitment_cat'); ?>								
        </select>
    </div>
    <div class="clear"></div>
</div>

<form name="frmlist" method="post" action="">
    <div class="pull-left">
        <a href="javascript:docheckallnew(false, document.frmlist.chkid)" >Deselect All</a> |
        <a href="javascript:docheckallnew(true, document.frmlist.chkid)" >Select All</a>
    </div>
    <div class="pull-right">
        <img src="images/icons/add.png" onclick="add();" class="pointer"/> 
        <img src="images/icons/delete.png" onclick="delall();" class="pointer"/> 
    </div>
    <div class="clear"/>

    <table width="100%" border="0" cellpadding="0" cellspacing="1" class="gridtitle">
        <tr>
            <td  class="gridtitletitle">
                <div class="divcheck">&nbsp;</div>
                <div class="divtitle">Title</div>
                <div class="divaction">Action</div>											</td>
        </tr>

        <tr >
            <td >
                <div id="changeNotificationNo"> </div>  
                <div id="sortlist">  												
                    <?php
                    foreach ($items as $key => $row) {

                        if ($key + 1 % 2 == 1)
                            $listitem = "griditem1";
                        else
                            $listitem = "griditem2";
                        ?>
                        <li class="<?= $listitem ?>" onMouseOver="mOvr(this, 'bgover')" onMouseOut="mOut(this, '<?= $listitem ?>')" id="pictureId_<?= $row['id'] ?>">
                            <div class="divcheck"><input type="checkbox" name="chkid" value="<?= $row["id"] ?>" /></div>
                            <div class="divtitle"><?= $row['title'] ?></div>
                            <div class="divaction"> <img src="images/icons/edit.png" onclick="edit('<?= $row["id"] ?>')" class="pointer"/>&nbsp;&nbsp;&nbsp;<img src="images/icons/del.png" onclick="del('<?= $row["id"] ?>')" class="pointer" /></div>
                            <!--
                            <div class="divmore_2"><input name="txtId[]" type="hidden" value="<?= $row["id"] ?>" /> <input name="txtFeatured[]" type="checkbox" value="<?= $row["id"] ?>" <?php if ($row["featured"] == 1) echo "checked"; ?> /></div>
                            <div class="divmore_2"><input name="txtNew[]" type="checkbox" value="<?= $row["id"] ?>" <?php if ($row["new"] == 1) echo "checked"; ?> /></div>
                            -->
                            <div class="clr"></div>
                        </li>

                        <?php
                    }
                    ?>   
                </div>	</td>	
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0">

        <tr>
            <td colspan="2" align="left" valign="middle" class="titlepage"><?= $lb_tottalrow ?>  <span class="numpage"><?= $totalrows ?></span> </td>
            <td colspan="3" align="right" valign="top" class="numpage"><?php echo $paging->pagenew($totalrows, $perpage, $pagecount, $curpg, $gotopage, "", "titlepage"); ?></td>
        </tr>

    </table>

    <input type="hidden" name="form_" value="delete" />		
    <input type="hidden" name="listid" value="" />
    <input type="hidden" name="curpg" value="<?= $curpg ?>" />
</form>